<?php

namespace App\Models\ModelManage;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Database
 * @package App\Models\ModelManage
 * @version August 9, 2018, 5:40 pm CST
 *
 * @property string name
 * @property string title
 * @property string description
 */
class Database extends Model
{
    use SoftDeletes;

    public $table = 'databases';

    protected $dates = ['deleted_at'];

    public $fillable = [
        'name',
        'title',
        'description',
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'name'        => 'string',
        'title'       => 'string',
        'description' => 'string',
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'name' => 'required|max:100',
    ];

    /**
     * 表
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function tables()
    {
        return $this->hasMany(\App\Models\ModelManage\Table::class, 'database_id', 'id');
    }

}
